package com.bkhc.product.repository;

import com.bkhc.product.entity.BrandGoodPrice;
import com.bkhc.product.entity.Goods;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.util.StringUtils;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.util.ArrayList;
import java.util.List;

@Repository
public interface BrandGoodPriceRepository extends JpaRepository<BrandGoodPrice,String> , JpaSpecificationExecutor<BrandGoodPrice> {

    @Query("SELECT  u FROM  BrandGoodPrice u WHERE u.brandCode=?1 AND u.goodsCode=?2 AND u.status='1'")
    List<BrandGoodPrice> findByBrandCodeAndGoodsCode(String brandCode,String goodsCode);

    @Query("SELECT  u FROM  BrandGoodPrice u WHERE u.brandCode=:brandCode AND u.goodsCode in (:goodsCodes) AND u.status='1'")
    List<BrandGoodPrice> findByBrandCodeAndGoodsCodeList(@Param("brandCode") String brandCode, @Param("goodsCodes") List<String> goodsCodes);

    @Query("SELECT  u FROM  BrandGoodPrice u WHERE u.brandCode=?1 AND u.goodsCode=?2 AND u.indentity=?3 AND u.status='1'")
    BrandGoodPrice findByBrandCodeAndGoodsCodeAndIndentity(String brandCode,String goodsCode,String indentity);

    @Query("SELECT  u FROM  BrandGoodPrice u WHERE u.brandCode=?1 AND u.productCode=?2 AND u.indentity=?3 AND u.status='1' AND u.price<>0")
    List<BrandGoodPrice> findByBrandCodeAndProductCodeAndIndentity(String brandCode,String productCode,String indentity);


    List<BrandGoodPrice> findByProductCodeAndBrandCodeAndStatus(String productCode, String brandCode,String status);

    void deleteByProductCode(String productCode);

    List<BrandGoodPrice> findByBrandCodeAndGoodsCodeAndStatus(String brandCode, String productCode, String s);

//    @Query(value = "select * from BrandGoodPrice  where price<>0")
//    BrandGoodPrice brandGoodPrice(String productCode,String brandCode);
}
